﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GrouponDesktop.AbmProveedor
{
    public partial class ABMProvee : Form
    {
        public ABMProvee()
        {
            InitializeComponent();
            dgv_prov.ReadOnly = true;
            dgv_prov.AllowUserToAddRows = false;
            BDConnection.FillGrid("select razon_social , dominio, CUIT, b.ciudad, c.rubro, id_proveedores from CodingSpree.TL_PROVEEDORES a, CodingSpree.TL_CIUDADES b, CodingSpree.TL_RUBROS c WHERE a.id_ciudad = b.id_ciudad and a.id_rubro = c.id_rubro ", dgv_prov);
            dgv_prov.Columns[0].Width = 115;
            dgv_prov.Columns[1].Width = 115;
            dgv_prov.Columns[2].Width = 140;
            dgv_prov.Columns[3].Width = 70;
            dgv_prov.Columns[4].Width = 70;
            dgv_prov.Columns[5].Visible = false;
            dgv_prov.Rows[0].Selected = true;

        }

        private void b_alta_Click(object sender, EventArgs e)
        {
            AltaProvee ap = new AltaProvee();
            ap.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            BDConnection.FillGrid("EXEC CodingSpree.buscProv '" + tb_f1.Text + "' ,'" + tb_f3.Text + "' ,'"  + tb_f2.Text + "'", dgv_prov);
            dgv_prov.Columns[0].Width = 115;
            dgv_prov.Columns[1].Width = 115;
            dgv_prov.Columns[2].Width = 150;
            dgv_prov.Columns[3].Width = 70;
            dgv_prov.Columns[4].Width = 70;
            dgv_prov.Columns[5].Visible = false;
            if (dgv_prov.Rows.Count > 0)
            {
                dgv_prov.Rows[0].Selected = true;
            }
        }

        private void b_baja_Click(object sender, EventArgs e)
        {
            BajaProv BP = new BajaProv((int)dgv_prov.SelectedRows[0].Cells["id_proveedores"].Value);
            BP.Show();
        }

        private void b_modif_Click(object sender, EventArgs e)
        {
            ModifProv MP = new ModifProv((int)dgv_prov.SelectedRows[0].Cells["id_proveedores"].Value);
            MP.Show();
        }
    }
}
